#pragma once
#include <string>
#include <vector>
#include "../math/vec3.h"
#include "../math/quat.h"
#include "../math/mat4.h"
#include "../renderer/ui/sprite.h"
#include "../renderer/ui/label.h"


class Node
{
private:
    Vec3 _position{};
    Vec3 _worldPosition{};
    Quat _rotation{};
    Vec3 _scale{1, 1, 1};
    Mat4 _localMatrix{};
    Mat4 _worldMatrix{};

    Sprite *_sprite = nullptr;
    Label *_label = nullptr;


public:
    std::string name;
    bool enabled;
    /**
     * @brief 父节点
     */
    Node *parent;
    /**
     * @brief 子节点
     */
    std::vector<Node *> children;

    Node();
    void addChild(Node *node);
    void setName(std::string name);
    void setPosition(float x, float y, float z);
    void setRotation(float x, float y, float z, float w);
    void setScale(float x, float y, float z);
    Vec3 &position();
    Vec3 &worldPosition();
    Quat &rotation();
    Vec3 &scale();
    Mat4 &localMatrix();
    Mat4 &worldMatrix();

    void updateWorldTransform();

    /**
     * @brief 添加ui精灵
     */
    void addSprite();
    void setSpriteSize(float width, float height);
    void setSpriteAnchor(float x, float y);
    void setSpriteColor(float r, float g, float b, float a);
    void setSpriteTexture(std::string path);
    Size &spriteSize();

    /**
     * 添加ui 文本
     */
    void addLabel();
    void setLabelText(std::string text);
    // std::string &labelText();




    void update(float deltaTime);

    ~Node();
};